/**
 * 打开弹窗
 * @param id 弹窗id
 */
function openDialog(id) {
    let htmlDivElement = document.createElement("div");
    htmlDivElement.classList.add("my-dialog-back");
    let htmlBodyElement = document.querySelector("body");
    htmlBodyElement.append(htmlDivElement);
    let elementById = document.getElementById(id);
    elementById.style.removeProperty("display");
}

/**
 * 在弹窗上打开第二个弹窗
 */
function openDialogWithBackgroundIdAndZIndex(id, backgroundId,zIndex){
    if(!document.getElementById(backgroundId)){
        let htmlDivElement = document.createElement("div");
        htmlDivElement.id=backgroundId;
        htmlDivElement.classList.add("my-dialog-back");
        htmlDivElement.style.zIndex=String(zIndex);//比一般的弹窗大
        let htmlBodyElement = document.querySelector("body");
        htmlBodyElement.append(htmlDivElement);
    }
    let elementById = document.getElementById(id);
    elementById.style.removeProperty("display");
    elementById.style.zIndex=String(zIndex+1);//比背景大
}


/**
 * 打开弹窗修改标题
 */
function openDialogWithTitle(dialogId,title){
    let element = document.querySelector("#"+dialogId+">.my-dialog-header>span");
    element.textContent=title;
    openDialog(dialogId);
}


/**
 * 关闭弹窗
 * @param id 弹窗id
 */
function closeDialog(id) {
    let elementById = document.getElementById(id);
    elementById.style.display = "none";
    let element = document.querySelector(".my-dialog-back");
    element.remove();
}
/**
 * 在弹窗上关闭第二个弹窗
 */
function closeDialogWithBackgroundId(id, backgroundId) {
    let elementById = document.getElementById(id);
    elementById.style.display = "none";
    let element = document.getElementById(backgroundId);
    element.remove();
}